(function($) {  
  $.fn.mumayitips = function(options) {  
    
		var opts = $.extend({}, $.fn.mumayitips.defaults, options);  
		return this.each(function() {  
		$this = $(this);  
		var o = $.meta ? $.extend({}, opts, $this.data()) : opts; 

		$.fn.mumayitips.addhtml(o.messages);
		$(".w206").show();

		switch(o.type){
			//show slide message
		   case 1:{
			   
				var oldtop=$.fn.mumayitips.getPageScroll()[1] +$.fn.mumayitips.getPageHeight();
				var tiptop=$.fn.mumayitips.getPageScroll()[1] + ($.fn.mumayitips.getPageHeight() /2)-50;
				var left=$(window).width() / 2-100;
				
				$("#tips_Content").css({"top":oldtop,"left": left});
				$(".w206").animate({"top": tiptop,"left":left}, 250);
			   break;
			
			}
            
			//show shake message
			case 2:{
				var offset = $this.offset(); 
				var oldtop=offset.top-$this.height()-50;
				var left=offset.left+$this.width()+20;

				var tiptop =offset.top+$this.height()-180;
				$("#tips_Content").css({"top":oldtop,"left": left});
				var i=0;
				for(i=0;i<=10;i++){
					$(".w206").animate({ "left": "+=5px"}, 5).animate({"left": "-=5px"},5);
				}
				break;
			}

			//show slide message
		   case 3:{
				var offset = $this.offset(); 
				
				var oldtop=($(window).height() - $this.height() ) / 2+$(window).scrollTop() -50+ "px";
				var left=$(window).width() / 2-100;
				$("#tips_Content").css({"top":oldtop,"left": left});
				var i=0;
				for(i=0;i<=10;i++){
					//$(".w206").animate({ "top": "+=5px"}, 10).animate({"top": "-=5px"},10);
					$(".w206").animate({ "left": "+=5px"}, 5).animate({"left": "-=5px"},5);
				}
			   break;
			
			}

		}
		//close tips
		$.fn.mumayitips.close(o.times);

    });
  };


  $.fn.mumayitips.addhtml = function(txt) { 
	  $("#tips_Content").remove();
	  $("body").append('<div  class="w206 center" id="tips_Content"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="info_not"><tr><td class="top_l"></td><td class="top_c"></td><td class="top_r"></td></tr><tr><td class="mid_l"></td><td class="mid_c"><div class="bg_333 font14 tc c_fff padtb15" id="tips_ShowMessages">'+txt+'</div></td><td class="mid_r"></td></tr><tr><td class="bot_l"></td><td class="bot_c"></td><td class="bot_r"></td></tr></table></div>');  
  }; 
  
  $.fn.mumayitips.defaults = {  
		messages: 'Success!',
		type:1,
		times:1000
  };
	/*
	$.fn.mumayitips.center = function (this) {
		this.css("position","absolute");
		this.css("top", ($(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
		this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
		return this;
	}*/

  

  $.fn.mumayitips.getPageHeight= function() {
    var windowHeight
    if (self.innerHeight) {	// all except Explorer
      windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
      windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
      windowHeight = document.body.clientHeight;
    }
    return windowHeight;
  }


  $.fn.mumayitips.getPageScroll= function() {
    var xScroll, yScroll;
    if (self.pageYOffset) {
      yScroll = self.pageYOffset;
      xScroll = self.pageXOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
      yScroll = document.documentElement.scrollTop;
      xScroll = document.documentElement.scrollLeft;
    } else if (document.body) {// all other Explorers
      yScroll = document.body.scrollTop;
      xScroll = document.body.scrollLeft;
    }
    return new Array(xScroll,yScroll)
  }

  $.fn.mumayitips.close= function(times) {
	  setTimeout(function(){
		$("#tips_Content").fadeOut("slow");
		//$("#tips_Content").remove();
	  }, times);
	  return 
  }

	$.fn.mumayitips.getAllPageHeight= function() {
			var xScroll, yScroll;
			if (window.innerHeight && window.scrollMaxY) {	
				xScroll = window.innerWidth + window.scrollMaxX;
				yScroll = window.innerHeight + window.scrollMaxY;
			} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
				xScroll = document.body.scrollWidth;
				yScroll = document.body.scrollHeight;
			} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
				xScroll = document.body.offsetWidth;
				yScroll = document.body.offsetHeight;
			}
			var windowWidth, windowHeight;
			if (self.innerHeight) {	// all except Explorer
				if(document.documentElement.clientWidth){
					windowWidth = document.documentElement.clientWidth; 
				} else {
					windowWidth = self.innerWidth;
				}
				windowHeight = self.innerHeight;
			} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
				windowWidth = document.documentElement.clientWidth;
				windowHeight = document.documentElement.clientHeight;
			} else if (document.body) { // other Explorers
				windowWidth = document.body.clientWidth;
				windowHeight = document.body.clientHeight;
			}	
			// for small pages with total height less then height of the viewport
			if(yScroll < windowHeight){
				pageHeight = windowHeight;
			} else { 
				pageHeight = yScroll;
			}
			// for small pages with total width less then width of the viewport
			if(xScroll < windowWidth){	
				pageWidth = xScroll;		
			} else {
				pageWidth = windowWidth;
			}
			arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
			return arrayPageSize;
	};



})(jQuery);